package com.example.star.service;

import com.example.star.entity.Favorite;
import com.example.star.entity.Feedback;
import com.example.star.entity.Follow;
import com.example.star.entity.Reply;
import com.example.star.mapper.FeedbackMapper;
import com.example.star.mapper.ReplyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedbackService {
    @Autowired
    private FeedbackMapper feedbackMapper;

    public void createFeedback(Feedback feedback) {
        feedbackMapper.insertFeedback(feedback);
    }

    public List<Feedback> getAllFeedbacks() {
        return feedbackMapper.getAllFeedbacks();
    }

    public List<Feedback> getFeedbacksByAdminName(String adminName) {
        return feedbackMapper.getFeedbacksByAdminName(adminName);
    }

    public List<Feedback> getFeedbackByPage(int page, int size) {
        int offset = (page - 1) * size;
        return feedbackMapper.getFeedbackByPage(offset, size);
    }
    public int getTotalFeedback() {
        return feedbackMapper.getTotalFeedback();
    }

    public void deleteFeedbackById(int id) {
        feedbackMapper.deleteFeedbackById(id);
    }

    // 分页查询指定用户的信息
    public List<Feedback> getFeedbackByUserPage(String userName, int page, int size) {
        int offset = (page - 1) * size;
        return feedbackMapper.getFeedbackByUserPage(userName, offset, size);
    }

    // 获取指定用户的总数
    public int getTotalFeedbackByUser(String userName) {
        return feedbackMapper.getTotalFeedbackByUser(userName);
    }
}

